import java.util.Map;

public class Word{
    
	private int wordnumber=0;
	private int charnumber=0;
	private int line=0;
	private Map<String,Integer> wordcount;
	String text;
	public Word(String text) {
		this.text = text;
	}
	public int getWordnumber() {
		String str=text;
		String[] words=str.split("\\s*[^0-9a-zA-Z]+");
		for(String s:words) {
			if(s.matches("[a-zA-Z]{4,}[a-zA-Z0-9]*")) {
				wordnumber++;
			}
		}
		return wordnumber;
	}
	public int getCharnumber() {
		for(int i=0;i<text.length();i++) {
			char c=text.charAt(i);
			if(c > 31 && c < 127 ||c == 10) {
				charnumber++;
			}
		}
		return charnumber;
	}
	public int getLine() {
		String[] lines=text.split("\r\n");
		for(int i=0;i<lines.length;i++) {
			if(lines[i].trim().length()!=0) {
			    line++;
			}
		}
		return line;
	}
	public Map getWordcount() {
		String []wordnum=text.split("\\s");
		for(int i=0;i<wordnum.length;i++) {
			if(wordnum[i].length()>=4) {
				char c;
				for (int j = 0; j < 4; j++) {
					c = wordnum[i].charAt(j);
					if (!(c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z')) {
						if(wordcount.get(wordnum[i]) != null) {
							wordcount.put(wordnum[i], wordcount.get(wordnum[i])+1);
							
						}
						else {
							wordcount.put(wordnum[i], 1);
						}
					}
			}
		}
	}
		return wordcount;
	
}        
	}
